function is(num) {
  const res = [];
  for (let i = 1; i < num; i++) {
    if (num % i === 0) {
      res.push(i);
    }
  }
  let sum = res.reduce((acc, cur) => {
    return acc + cur;
  }, 0)
  if (num === sum) {
    return true;
  } else {
    false;
  }
}

function fn() {
  const res = [];
  for (let i = 1; i <= 1000; i++) {
    if (is(i)) {
      res.push(i)
    }
  }
  return res;
}

console.log(fn());